home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / fsp-2.7 / fsp-2 / fsp / clients / fprocmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-21  |  2.6 KB  |  105 lines

  1.     /*********************************************************************\
  2.     *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  3.     *                                                                     *
  4.     *  You may copy or modify this file in any manner you wish, provided  *
  5.     *  that this notice is always included, and that you hold the author  *
  6.     *  harmless for any loss or damage resulting from the installation or *
  7.     *  use of this software.                                              *
  8.     \*********************************************************************/
  9.  
  10. #include "tweak.h"
  11. #include "client_def.h"
  12. #include "c_extern.h"
  13. #include "bsd_extern.h"
  14.  
  15. #define Y_or_N(y) ((flags & (y)) ?  "Y" : "N")
  16. #define Machine(y) ((flags & (y)) ? "you" : "other")
  17.  
  18. static int print_pro PROTO1(char *, p)
  19. {
  20.   char *op, flags;
  21.   unsigned len, len1;
  22.   UBUF *ub;
  23.   char *pro1, *pro2;
  24.   
  25.   op = util_abs_path(p);
  26.   
  27.   ub = client_interact(CC_GET_PRO,0L, strlen(op), (unsigned char *)op+1, 0,
  28.                (unsigned char *)NULLP);
  29.   len = BB_READ2(ub->bb_len); len1 = BB_READ4(ub->bb_pos);
  30.   pro1 = ub->buf; pro2 = ub->buf+len;
  31.   
  32.   printf("%s\t: ",p);
  33.   
  34.   if(len1) {
  35.     flags = *pro2;
  36.     printf("(owner: %s)(del: %s)(create: %s)(mkdir: %s)(private: %s)\n",
  37.        Machine(DIR_OWNER), Y_or_N(DIR_DEL), Y_or_N(DIR_ADD),
  38.        Y_or_N(DIR_MKDIR), Y_or_N(DIR_PRIV));
  39.   }
  40.   printf("%s", pro1);
  41.   printf("\n");
  42.   
  43.   return(0);
  44. }
  45.  
  46. static int set_pro PROTO2(char *, p, char *, key)
  47. {
  48.   char *op, flags;
  49.   unsigned len1, len;
  50.   UBUF *ub;
  51.   char *pro1, *pro2;
  52.   
  53.   op = util_abs_path(p);
  54.   
  55.   ub = client_interact(CC_SET_PRO,0L, strlen(op), (unsigned char *)op+1,
  56.                strlen(key)+1, (unsigned char *)key);
  57.   len = BB_READ2(ub->bb_len); len1 = BB_READ4(ub->bb_pos);
  58.   pro1 = ub->buf; pro2 = ub->buf+len;
  59.   
  60.   printf("%s\t: ",p);
  61.   
  62.   if(len1) {
  63.     flags = *pro2;
  64.     printf("(owner: %s)(del: %s)(create: %s)(mkdir: %s)(private: %s)\n",
  65.        Machine(DIR_OWNER), Y_or_N(DIR_DEL), Y_or_N(DIR_ADD),
  66.        Y_or_N(DIR_MKDIR), Y_or_N(DIR_PRIV));
  67.   }
  68.   printf("%s", pro1);
  69.   printf("\n");
  70.   
  71.   return(0);
  72. }
  73.  
  74. int main PROTO3(int, argc, char **, argv, char **, envp)
  75. {
  76.   char **av, *av2[2], *key;
  77.   
  78.   env_client();
  79.   
  80.   if(argv[1] && (argv[1][0] == '+' || argv[1][0] == '-') && !argv[1][2]) {
  81.     key = *++argv;
  82.     while(*++argv) {
  83.       if(!(av = glob(*argv))) {
  84.     av = av2;
  85.     av2[0] = *argv;
  86.     av2[1] = 0;
  87.       }
  88.       while(*av) set_pro(*av++,key);
  89.     }
  90.   } else {
  91.     if(argv[1]) while(*++argv) {
  92.       if(!(av = glob(*argv))) {
  93.     av = av2;
  94.     av2[0] = *argv;
  95.     av2[1] = 0;
  96.       }
  97.       while(*av) print_pro(*av++);
  98.     } else print_pro(".");
  99.   }
  100.   
  101.   client_done();
  102.   
  103.   exit(0);
  104. }
  105.